<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>

<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title></title>
    <script>
        function showFiles() {
            var fileSection = document.getElementById("fileSection");
            fileSection.style.display = "block";
        }
    </script>
</head>

<body>
<h2>共享群组成员：</h2>
    <ul>
        <c:forEach var="memberName" items="${memberNames}">
            <li>${memberName}</li>
        </c:forEach>
    </ul>
<h2>已共享的文件：</h2>
    <ul>
        <c:forEach var="groupFile" items="${groupFiles}">
            <li>${groupFile.filename}
                <a href="/file/preview?fileName=${groupFile.filename}" target="_blank"><button>预览</button></a>
                <a href="/file/download?fileName=${groupFile.filename}" target="_blank"><button>下载</button></a>
            </li>
        </c:forEach>
    </ul>
<h2>我共享的文件：</h2>
    <ul>
        <c:forEach var="mySharedFileName" items="${myShareFileNames}">
            <li>${mySharedFileName}
                <a href="/file/deleteShareFile?fileName=${mySharedFileName}&groupId=${groupId}"><button>取消共享</button></a>
            </li>
        </c:forEach>
    </ul>
<button onclick="showFiles()">共享文件</button>

    <div id="fileSection" style="display: none;">
        <h2>可共享的文件</h2>
        <form action="/file/doShareFile/" method="post">
            <c:forEach var="fileName" items="${uploadedFils}">
                <div>
                    <input type="checkbox" name="selectedFiles" value="${fileName}" />
                    <span>${fileName}</span>
                </div>
            </c:forEach>
            <input type="hidden" name="groupId" value="${groupId}" />
            <input type="submit" value="共享" />
        </form>
    </div>
</body>
</html>